{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "46\n"
     ]
    }
   ],
   "source": [
    "# pandas数据分析\n",
    "# 核心对象：series、dataframe\n",
    "import pandas as pd\n",
    "player = pd.read_json(\"cansaixuanshou_20240111.json\", encoding=\"UTF-8\")\n",
    "# print(player.columns)\n",
    "\n",
    "player_height = player[\"height\"]\n",
    "# print(type(player_height))\n",
    "player_height = player_height.str.slice(0,3).astype(int)\n",
    "\n",
    "acerage_height = player_height.mean()  #  求平均值\n",
    "\n",
    "# print(player_height.describe())  # 对整型数据得到统计数据\n",
    "\n",
    "player[\"height_int\"] = player_height\n",
    "# print(player.info())  # 打印二维表的信息\n",
    "\n",
    "# print(player.loc[player[\"height_int\"]>=180 ,\"name\"].count())\n",
    "\n",
    "\n",
    "player_weight = player[\"weight\"]\n",
    "player_weight = player_weight.str.slice(0,2).astype(int)\n",
    "player[\"weight_int\"] = player_weight\n",
    "print(player.loc[(player[\"weight_int\"]>=55) & (player[\"weight_int\"]<=60), \"name\"].count())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pytorch",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
